<template>
  <div v-cloak>
    <!-- banner区域 -->
    <div class="banner">
      <div class="text">
        <h4>
          容|联|七|陌
        </h4>
        <h3>
          用心做产品，用爱做服务
        </h3>
      </div>
    </div>
    <!-- 投诉 -->
    <div class="info">
      <h3>投诉</h3>
      <div class="info-content">
        <div class="right">
          <img src="../../assets/Images/service/contact.jpeg" alt="logo">
        </div>
        <div class="left">
          <div class="formbox">
            <form action='http://localhost:3100/postValue'>
              <span class="form-label">投诉内容：</span><input class="input-content" type="text" name="context"
                maxlength="50" /> <br> <br>
              <span class="form-label">联系方式：</span><input class="input-content" type="text" name="contact"
                maxlength="50" /> <br> <br>
              <span class="form-label">用&nbsp;户&nbsp;名&nbsp;：</span><input class="input-content" type="text" name="user"
                maxlength="50" /> <br>
              <br>
              <input class="buttom-box" type="submit" value="提交" onclick="submit()" />
            </form>
          </div>
        </div>
      </div>
    </div>
    <!-- footer -->
    <div class="footer">
      <div class="footer-content">
        <div class="bottom">
          Copyright © 2015-2023 北京七陌科技有限公司
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import VueAxios from 'vue-axios'
export default {
  data() {
    return {
      ruleForm: {
        uname: "",
        password: "",
      },
      rules: {
        uname: [
          { required: true, message: "用户名不能为空！", trigger: "blur" },
        ],
        password: [
          { required: true, message: "密码不能为空！", trigger: "blur" },
        ],
      },
      loading: false, // 是否显示加载动画
    };
  },
  methods: {
    submitForm(formName) {
      // 验证表单中的账号密码是否有效，因为在上面rules中定义为了必填 required: true
      this.$refs[formName].validate((valid) => {
        // 点击登录后，让登录按钮开始转圈圈（展示加载动画）
        this.loading = true;
        // 如果经过校验，账号密码都不为空，则发送请求到后端登录接口
        if (valid) {
          let _this = this;
          // 使用 axios 将登录信息发送到后端
          axios.get("/api/login", {
            method: "get",                       // 请求方法
            headers: {                            // 请求头
              "Content-Type": "application/json",
            },
            params: {                             // 请求参数
              userName: _this.ruleForm.uname,
              userPassword: _this.ruleForm.password,
            },
          }).then((res) => { // 当收到后端的响应时执行该括号内的代码，res 为响应信息，也就是后端返回的信息
            console.log(res)
            if (res.status === 200) {  // 当响应的编码为 0 时，说明登录成功
              // 将用户信息存储到sessionStorage中
              sessionStorage.setItem("userInfo", JSON.stringify(res.data.data));
              this.$message({
                message: res.data.msg,
                type: "success",
              });
              console.log("I'm in")
              // 跳转页面到首页
              this.$router.push('/chat?sendId=3');

              // 显示后端响应的成功信息

            } else {  // 当响应的编码不为 0 时，说明登录失败
              console.log(res.data.code)
              // 显示后端响应的失败信息
              this.$message({
                message: res.data.msg,
                type: "warning",
              });
            }
            // 不管响应成功还是失败，收到后端响应的消息后就不再让登录按钮显示加载动画了
            _this.loading = false;
            console.log(res);
          });
        } else {  // 如果账号或密码有一个没填，就直接提示必填，不向后端请求
          console.log("error submit!!");
          this.loading = false;
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    submit() {
      console.log("submit the pass and ");
    }
  },
};
</script>

<style scoped lang="less">
.banner {
  height: 280px;
  background: #1F2430;

  .text {
    width: 1100px;
    height: 210px;
    padding-top: 70px;
    margin: 0 auto;
    background-image: url(../../assets/Images/logo/banner.png);
    background-size: 1100px 280px;

    h4 {
      text-align: center;
      height: 42px;
      font-size: 30px;
      color: rgba(0, 175, 131, 1);
      line-height: 42px;
      letter-spacing: 30px;
    }

    h3 {
      text-align: center;
      height: 70px;
      font-size: 50px;
      margin-top: 12px;
      font-weight: 600;
      color: rgba(255, 255, 255, 1);
      line-height: 70px;
      letter-spacing: 16px;
    }
  }
}


.info {
  padding: 120px 0;

  h3 {
    height: 48px;
    font-size: 34px;
    font-weight: 400;
    color: rgba(39, 48, 69, 1);
    line-height: 48px;
    text-align: center;
  }

  .info-content {
    width: 1100px;
    margin: 0 auto;
    margin-top: 50px;
    display: flex;
    justify-content: space-evenly;

    .right {

      img {
        width: 369px;
        height: 238px;
      }
    }

    .left {
      width: 600px;
      display: flex;
      justify-content: center;
      align-items: center;

      .formbox {
        position: relative;

        .form-label {
          text-align: center;
          font-size: 16px;
          color: rgba(89, 101, 128, 1);
          line-height: 26px;
        }

        .input-content {
          border-radius: 5px;
          height: 20px;
        }

        .buttom-box {
          border: none;
          border-radius: 5px;
          position: absolute;
          bottom: -32px;
          right: 0px;
          width: 77px;
          height: 35px;
          font-size: 16px;
          color: #c4c4c4;
          background-color: #1f2430;
          transition: all 0.2s;

          &:hover {
            background-color: #0c705d;
            color: #fff;
          }
        }
      }
    }
  }
}


.footer {
  height: 75px;
  background: #1F2430;
  padding: 0 0 6px;

  .footer-content {
    width: 1100px;
    margin: 60px auto 0;
    background: #1F2430;


    .bottom {
      border-top: 1px solid #424854;
      color: #A5A6AB;
      float: left;
      width: 100%;
      text-align: center;
      padding-top: 24px;
    }
  }

}



// .help {
//   background: darkgray;
//   text-align: center;
// }

// .content {
//   text-align: center;
// }

// .headerimg {
//   text-align: center;
// }

// .d1 {
//   column-count: 2;
//   column-width: 50px;
//   column-height: 400px;
//   padding-bottom: 32767px;
//   column-span: none;
// }

// .multiColumn-e2 {
//   width: 800px;
//   margin: 30px auto;
//   box-sizing: border-box;
//   column-count: 2;
// }

// .multiColumn-e2 .box {
//   width: 300px;
//   margin: 0;
//   padding: 10px;
//   break-inside: avoid;
//   page-break-inside: avoid;
//   ;
// }

// .multiColumn-e2 .box p {
//   margin: 0;
//   width: 300px;
// }
</style>